package OfferAliBaBa.b_23年数马笔试;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int number = Integer.parseInt(reader.readLine());

        LinkedNode head = new LinkedNode();
        LinkedNode tail = new LinkedNode();
        // head.postNode = tail;
        // tail.preNode = head;
        buildLinkedList(head, tail);

        while (number != 0) {
            String[] command = reader.readLine().split(" ");
            if ("insert".equals(command[0])) {
                int value = Integer.parseInt(command[2]);
                int current = Integer.parseInt(command[1]);
                LinkedNode node = new LinkedNode(value);
                insertNode(head, tail, node, current);
            } else {
                int value = Integer.parseInt(command[1]);
                removeNode(head, tail, value);
            }
            number--;
        }

        print(head, tail);
    }

    public static void buildLinkedList(LinkedNode head, LinkedNode tail) {
        head.nextNode = tail;
        tail.preNode = head;
    }

    public static void insertNode(LinkedNode head, LinkedNode tail, LinkedNode node, int current) {
        LinkedNode pHead = head;

        while (pHead != tail) {
            if (pHead.value == current) {
                //找到被插得节点pHead
                pHead.pre().nextNode = node;
                node.preNode = pHead.pre();

                pHead.preNode = node;
                node.nextNode = pHead;
                break;
            }
            pHead = pHead.next();
        }

        if (pHead == tail) {
            //不存在被插节点
            tail.pre().nextNode = node;
            node.preNode = tail.pre();

            node.nextNode = tail;
            tail.preNode = node;
        }
    }

    public static void removeNode(LinkedNode head, LinkedNode tail, int current) {
        LinkedNode pHead = head;

        while (pHead != tail) {
            if (pHead.value == current) {
                //找到被删除节点pHead
                pHead.pre().nextNode = pHead.next();
                pHead.next().preNode = pHead.pre();
                break;
            }
            pHead = pHead.next();
        }

    }

    public static boolean isEmpty(LinkedNode head, LinkedNode tail) {
        return head.nextNode == tail;
    }

    public static void print(LinkedNode head, LinkedNode tail) {
        if (isEmpty(head, tail)) {
            System.out.println("NULL");
        } else {
            LinkedNode pHead = head;
            while (pHead != tail) {

                pHead = pHead.next();
                if (pHead == tail) {
                    break;
                }
                if (pHead == tail.pre()) {
                    System.out.print(pHead.value);
                } else {
                    System.out.print(pHead.value + " ");
                }
            }
        }
    }

}

class LinkedNode {
    LinkedNode preNode = null;
    LinkedNode nextNode = null;
    int value = -1;

    public LinkedNode(LinkedNode preNode, LinkedNode nextNode, int value) {
        this.preNode = preNode;
        this.nextNode = nextNode;
        this.value = value;
    }

    public LinkedNode(int value) {
        this.value = value;
    }

    public LinkedNode() {
    }

    public LinkedNode next() {
        return nextNode;
    }

    public LinkedNode pre() {
        return preNode;
    }

    public LinkedNode getPreNode() {
        return preNode;
    }

    public void setPreNode(LinkedNode preNode) {
        this.preNode = preNode;
    }

    public LinkedNode getNextNode() {
        return nextNode;
    }

    public void setNextNode(LinkedNode nextNode) {
        this.nextNode = nextNode;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}
/*
5
insert 0 1
insert 0 3
insert 1 2
insert 3 4
delete 4
 */